package Lib3d.Animation;


import Lib3d.Vector3d;

/**
 * A Bezier animation implementation. Note: this class is NOT ready!
 * 
 * @author Wassim Chegham
 * @version 0.1
 * @category Lib3d.Animation
 * 
 */
public class BezierAnimation extends SimpleAnimationImpl {
    static final Vector3d[][] ctrlpoints = {
            {
                    new Vector3d(-4.0f, -4.0f, -4.0f), new Vector3d(-4.0f, -4.0f, -4.0f),
                    new Vector3d(-15.0f, -15.0f, -15.0f)
            },
            {
                    new Vector3d(-2.0f, -2.0f, -2.0f), new Vector3d(4.0f, 4.0f, 4.0f),
                    new Vector3d(-15.0f, -15.0f, -15.0f)
            },
            {
                    new Vector3d(2.0f, 2.0f, 2.0f), new Vector3d(-4.0f, -4.0f, -4.0f),
                    new Vector3d(-15.0f, -15.0f, -15.0f)
            },
            {
                    new Vector3d(4.0f, 4.0f, 4.0f), new Vector3d(4.0f, 4.0f, 4.0f),
                    new Vector3d(-15.0f, -15.0f, -15.0f)
            }
    };

    static final Vector3d[][] ctrlpoints2 = {
            {
                    new Vector3d(1.0f, 1.0f, 1.0f), new Vector3d(0.0f, 0.0f, 0.0f),
                    new Vector3d(0.0f, 0.0f, 0.0f), new Vector3d(1.0f, 1.0f, 1.0f)
            },
            {
                    new Vector3d(0.0f, 0.0f, 0.0f), new Vector3d(1.0f, 1.0f, 1.0f),
                    new Vector3d(0.0f, 0.0f, 0.0f), new Vector3d(1.0f, 1.0f, 1.0f)
            },
            {
                    new Vector3d(1.0f, 1.0f, 1.0f), new Vector3d(1.0f, 1.0f, 1.0f),
                    new Vector3d(1.0f, 1.0f, 1.0f), new Vector3d(1.0f, 1.0f, 1.0f)
            },
            {
                    new Vector3d(1.0f, 1.0f, 1.0f), new Vector3d(1.0f, 1.0f, 1.0f),
                    new Vector3d(1.0f, 1.0f, 1.0f), new Vector3d(1.0f, 1.0f, 1.0f)
            }
    };

    public BezierAnimation() {
        this(new Vector3d(0, 0, 0));
    }

    public BezierAnimation(final Vector3d translation) {
        // super(translation);
        final double tt = Math.random() * System.currentTimeMillis();
        final float x = (float) (Math.random() * System.currentTimeMillis());
        final float y = (float) (Math.random() * System.currentTimeMillis());
        final float z = (float) (Math.random() * System.currentTimeMillis());
        super.setAnimationFunction(new Vector3d(x, y, z));
    }
    //
    // @Override
    // public void draw(final GLAutoDrawable gLDrawable) {
    // final int tt = 1;
    // final GL gl = gLDrawable.getGL();
    // final float f = (float) (0.5 + Math.sin(tt / 500) / 2);
    // BezierAnimation.ctrlpoints2[0][0] = new Vector3d(f, f, f);
    // gl.glMap1f(GL.GL_MAP1_VERTEX_3, 0.0f, 1.0f, 3, 4,
    // BezierAnimation.ctrlpoints[0][0].toBuffer());
    // gl.glMap1f(GL.GL_MAP1_COLOR_4, 0.0f, 1.0f, 4, 4,
    // BezierAnimation.ctrlpoints2[0][0].toBuffer());
    // gl.glEnable(GL.GL_MAP1_VERTEX_3);
    // gl.glEnable(GL.GL_MAP1_COLOR_4);
    // gl.glBegin(GL.GL_LINE_STRIP);
    // for (float i = 0.0f; i <= 1; i += 0.01f) {
    // gl.glEvalCoord1f(i);
    // }
    // gl.glEnd();
    // gl.glDisable(GL.GL_MAP1_VERTEX_3);
    // gl.glDisable(GL.GL_MAP1_COLOR_4);
    // gl.glPointSize(5.0f);
    // gl.glColor3f(1.0f, 1.0f, 0.0f);
    // gl.glBegin(GL.GL_POINTS);
    // for (int j = 0; j < 4; j++) {
    // gl.glVertex2fv(BezierAnimation.ctrlpoints[j][0].toBuffer());
    // }
    // gl.glEnd();
    // }

}
